home *** CD-ROM | disk | FTP | other *** search
- Path: redstone.interpath.net!mercury!mccourry
- From: mccourry@mercury.interpath.net (Thomas L McCourry -- Personal Account)
- Newsgroups: comp.lang.c
- Subject: referencing c structures with inline assembly?
- Date: 6 Feb 1996 15:37:20 GMT
- Organization: Interpath -- Providing Internet access to North Carolina
- Message-ID: <4f7sjg$21h@redstone.interpath.net>
- NNTP-Posting-Host: mercury.interpath.com
- Summary: how do you reference c structures with inline assembly?
- Keywords: assembly structure
- X-Newsreader: NN version 6.5.0 #4 (NOV)
-
-
-
- Can someone tell me how to access parts of this structure using inline
- assembly language?
-
-
- HERE IS A STRUCTURE THAT I'M USING:
-
- typedef struct uart {
- int uart_data; // Data register
- int uart_ier; // Interrupt enable register
- int uart_iir; // Interrupt identification register
- int uart_lcr; // Line control register
- int uart_mcr; // Modem control register
- int uart_lsr; // Line status register
- int uart_msr; // Modem status register
-
- char com_installed; // Flag: Communications routines installed
- int intnum; // Interrupt vector number for chosen port
- char i8259bit; // 8259 bit mask
- char old_i8259_mask; // Copy as it was when we were called
- char old_ier; // Modem register contents saved for
- char old_mcr; // restoring when we're done
- void interrupt (*old_vector)(); // Place to save COM1 vector
-
- unsigned char *tx_queue;
- int tx_in; // Index of where to store next character
- int tx_out;
- int tx_chars; // Count of characters in queue
-
- unsigned char *rx_queue;
- int rx_in; // Index of where to store next character
- int rx_out;
- int rx_chars; // Count of characters in queue
- } Uart;
-
-
- HERE IS PART OF A FUNCTION THAT USES THE STRUCTURE
- --------------------------------------------------
-
-
- void com_driver(register Uart *p) {
- char c;
-
- c = p->i8259bit;
-
- asm {
- in al,21h
- or al,[c] // disarm the interrupt, COM1=10h, COM2=08h
- out 21h,al
- mov al,20h // acknowledge interrupt
- out 20h,al
- }
-
-
- HERE IS WHAT I WANT TO DO:
- --------------------------
-
-
- void com_driver(register Uart *p) {
-
- asm {
- in al,21h
- or al,[p->i8259bit] // disarm the interrupt, COM1=10h, COM2=08h
- out 21h,al
- mov al,20h // acknowledge interrupt
- out 20h,al
- }
-
-
- That is, I would like to acces the structure in assembly language. The second
- function doesn't compile. How do you reference this byte in the structure using
- only assembly language. I'm using the Borland C/C++ compiler.
-
- thanks,
-
- Larry McCourry
- mccourry@mercury.interpath.com
-
- --
- I think I've got the hang of it now .... :w :q :wq :wq! ^d X exit ^X^C ~.
- ^[x X Q :quitbye CtrlAltDel ~~q :~q logout save/quit :!QUIT ^[zz ^[ZZ
- ZZZZ ^H ^@ ^L ^[c ^# ^E ^X ^I ^T ? help helpquit ^D ^d ^C ^c help
- ^]q exit ?Quit ?q (stolen from Norm Ahlquist) mccourry@mercury.interpath.com
-